package com.thb.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
	
	/**
	 * SIMPLE_DATE = "yyyy-MM-dd HH:mm";
	 * @param date
	 * @return
	 */
	public static final String SIMPLE_DATE = "yyyy-MM-dd HH:mm";
	
	/**
	 * LONG_SIMPLE_DATE = "yyyy-MM-dd HH:mm:ss"
	 */
	public static final String LONG_SIMPLE_DATE = "yyyy-MM-dd HH:mm:ss";
	
	/**
	 * yyyyMM
	 */
	public static final String SHORT_SIMPLE_DATE = "yyyyMM";
	
	
	public static String formatToString(Date date,String pattern){
		SimpleDateFormat sf = new SimpleDateFormat(pattern);
		return sf.format(date);
	}
	
	public static Date formatToDate(String date,String pattern){
		try {
			SimpleDateFormat sf = new SimpleDateFormat(pattern);
			return sf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
		return null;
	}

}
